program time;

{$APPTYPE CONSOLE}
uses
  Windows;
const
n = 10000;
var
a : array of integer;
i, t, tim : integer;
procedure BubbleSort;
var i, j, temp : integer;
begin
  for i:=0 to n-2 do
    for j:=0 to n-2-i do
    begin
      if a[i]>a[i+1] then
      begin
       temp := a[i];
       a[i] := a[i+1];
       a[i+1] := temp;
      end;
    end;
end;

begin
  setlength(a, n);
  for i:=0 to n-1 do
    a[i] := random(50);
  t := GetTickCount;
  BubbleSort;
  tim := GetTickCount;
  tim := tim - t;
  writeln(tim);
  readln;
end.
 